/*
 * @Author: WuFeng <763467339@qq.com>
 * @Date: 2022-07-14 14:57:14
 * @LastEditTime: 2023-04-18 17:09:46
 * @LastEditors: WuFeng <763467339@qq.com>
 * @Description: 角色管理
 * @FilePath: \vue3-element-plus-web\src\api\SysManage\role.js
 * @Copyright 版权声明
 */
import request from '@/utils/request'
import qs from 'qs'

/**
 * @description 获取列表
 */
export function getList(params) {
  const data = params
  return request({
    url: '/role/page',
    method: 'get',
    params: data
  })
}

/**
 * @description 获取列表 - 不分页
 */
export function getAllList(params) {
  const data = params || {}
  if (typeof data.size === 'undefined') {
    data.size = 9999
  }
  return request({
    url: '/role/list',
    method: 'get',
    params: data
  })
}

/**
 * @description 添加保存
 * @param {*} params
 */
export function addSave(params) {
  const data = params
  return request({
    url: '/role/save',
    method: 'post',
    data
  })
}

/**
 * @description 编辑保存
 * @param {*} params
 */
export function updateSave(params) {
  const data = params
  return request({
    url: '/role/submit',
    method: 'post',
    data
  })
}

/**
 * @description 删除保存
 * @param {*} params
 */
export function deleteSave(params) {
  const data = params
  return request({
    url: '/role/remove',
    method: 'post',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    data: qs.stringify(data)
  })
}

/**
 * @description 角色授权：获取资源树及角色拥有哪些权限
 * @param {String} roleId 角色ID
 */
export function getRoleMenuList(params) {
  const data = params
  return request({
    url: '/role/menuList',
    method: 'get',
    params: data
  })
}

/**
 * @description 角色授权 - 保存
 * @param {*} params
 */
export function submitPremission(params) {
  const data = params
  return request({
    url: '/role/submitPremission',
    method: 'post',
    data
  })
}

export default {}
